from pdb import set_trace as D

class Namespace(object):
   '''A convenience class that wraps a callable.
   Provides x.y, x['y'] and x('y') syntax.'''

   def __init__(self, callable):
       self.callable = callable

   def __getattribute__(self, name):
       return object.__getattribute__(self, 'callable')(name)

   __getitem__ = __call__ = __getattribute__

def struct(**kwds):
    '''A convenience function that returns a namespace object using
    named arguments passed to this function. Similar to a dict().'''
    return Namespace(kwds.get)


if __name__ == '__main__':
    pass
